#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>

#define TL 1000
#define PL 100
#define M 100
using namespace std;

int n,m;
char t[TL];
char p[M][PL];
int f[M*PL];
vector<int> matched[M*PL];
int edge[M*PL][30]; // alphabet : 'a'-'z'
int node;
queue<int> q;

int main(){
    int i,j,k,l,c,r;

    // Input
    scanf("%s",&t);
    scanf("%d ",&m);
    for(i = 0; i < m;i++){
        scanf("%s",&p[i]);
    }

    node = 1;
    f[0] = 0; 
    for(i = 0; i < m;i++){
        c = 0;
        l = strlen(p[i]);
        for(j = 0; j < l; j++){
            k = p[i][j]-'a';
            if (edge[c][k] != 0){
                c = edge[c][k];
            } else {
                edge[c][k]=node;
                c = node++;
            }
        }
        matched[c].push_back(i);
    }

    int u,v;
    q.push(0);
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(i = 0; i < 26; i++) {
            if (edge[u][i] == 0) continue;
            v = edge[u][i];
            q.push(v); 
            r = f[u];
            while (r != 0 && edge[r][i]==0) {
                r = f[r];
            }
            if (u ==0 || edge[r][i] == 0) {
                f[v] = 0;
            } else {
                f[v] = edge[r][i];
                vector<int>::iterator it;
                for(it = matched[f[v]].begin();
                    it != matched[f[v]].end(); it++){
                    matched[v].push_back(*it);
                }
            }
        }
    }

    n = strlen(t);
    c = 0;
    for(i = 0; i < n; i++){
        while(c > 0 && edge[c][t[i]-'a'] == 0)
            c = f[c];
        if (edge[c][t[i]-'a'] != 0) {
            c = edge[c][t[i]-'a'];
            if (matched[c].size() == 0) continue;
            printf("position %d: ", i);
            vector<int>::iterator it;
            for(it = matched[c].begin(); it != matched[c].end(); it++){
                printf("%d ", *it);
            }
            printf("\n");
        }
    }
    return 0;
}
